home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1997 February / Software of the Month Club 1997 February.iso / pc / dos / edu / calc / fit2peak.bat < prev    next >
Encoding:
DOS Batch File  |  1996-10-28  |  793 b   |  26 lines

  1. rem fitting a function with 2 peaks with 2 Gaussians:
  2. calc x = {-10,10,0.1}
  3. calc y = 15*G((x-1.1)/1.2)+11*G((x+2.2)/0.8)+3.3+0.5*sin(10*x)
  4. calc y "Original function y ->" "x ->"
  5. calc coef = Fitc(y,G(14,1,1)+G(10,-2,1)+3)
  6. rem compare the above best fit coefficients and the original expression for y:
  7. rem original y = 15*G((x-1.1)/1.2)+11*G((x+2.2)/0.8)+3.3+sin(3*x)
  8. @pause
  9. calc fitted(coef,x) "Best Fit ->" "x ->"
  10. @if errorlevel 1 goto fin
  11. @pause
  12. rem fitted(coef,x) is a best fitted function:
  13. calc max(fitted(coef,x)-y)
  14. rem these are fitting coefficients:
  15. rem A - amplitude, X - position, W - width of the n-th peak.
  16. rem Co - constant term.
  17. @echo off
  18. calc An(coef,1)
  19. calc Xn(coef,1)
  20. calc Wn(coef,1)
  21. calc An(coef,2)
  22. calc Xn(coef,2)
  23. calc Wn(coef,2)
  24. calc Co(coef)
  25. : fin
  26.